<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.2.1.min.js"></script>
    <script>
        function reg() {
            $.post("/user/reg",$("#f1").serialize(),function (info) {
                // alert(info);
                // console.log(info);
                if(info =="ok"){
                    $("#infoSpan").html("通过");
                }
                else{
                    var str = "";
                    // console.log(info);
                    // alert(info.length)
                    var errorList = eval(info);
                    for(var i=0;i<errorList.length;i++){
                        str += errorList[i].field+","+errorList[i].defaultMessage+"<br>";
                    }
                    $("#infoSpan").html(str);
                }
            });
        }
    </script>
</head>
<body>
    <form action="/user/add" method="post">
        用户名：<input type="text" name="userName"><br>
        <input type="submit" value="提交">
    </form>
<hr>
    <span id="infoSpan"></span>
    <form id="f1">
        学校名：<input type="text" name="schoolName"><br>
        email：<input type="text" name="email"><br>
        校长：<input type="text" name="schoolMaster"><br>
        <input type="button" value="注册" onclick="reg()">
    </form>
</body>
</html>